<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单控件的焦点2025年6月18日09:33:11</title>
    <script src="../../js/jquery-1.4.2.js"></script>
</head>
<body>
<input type="text" name="username"
       onblur="blurFu(this)" onfocus="focusFu(this)">
</body>
<script>
    //失去焦点
    function blurFu(thisObj) {
        if (thisObj.value == "") {
            thisObj.value = "请输入用户名"
        }
    }

    //获取交代你
    function focusFu(thisObj) {
        if (thisObj.value == "请输入用户名") {
            thisObj.value = ""
        }
    }
</script>
</html>